package leetcode;

/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q2550.java
 * @Author : WangRuoyu
 * @Date 2023/2/20 15:11
 */

public class Q2550 {
    public int monkeyMove(int n) {
        long MOD = 1000000007;
        long a = 2;
        long b = n;
        long ans = 1;
        while (b != 0) {
            if (b % 2 == 1) {
                b--;
                ans = ((ans % MOD) * (a % MOD)) % MOD;
            }
            b /= 2;
            a = (a % MOD) * (a % MOD);
        }
        return (int) ((ans - 2 + MOD) % MOD);
    }

    public static void main(String[] args) {
        Q2550 sl = new Q2550();
        int n = 4;
        System.out.println(sl.monkeyMove(n));
    }
}